package com.zp.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 图片编辑操作类型枚举
 */
@Getter
public enum PictureEditActionEnum {

    ZOOM_IN("放大操作", "ZOOM_IN"),
    ZOOM_OUT("缩小操作", "ZOOM_OUT"),
    ROTATE_LEFT("左旋操作", "ROTATE_LEFT"),
    ROTATE_RIGHT("右旋操作", "ROTATE_RIGHT");

    private final String text;
    private final String value;

    PictureEditActionEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    private static final Map<String, PictureEditActionEnum> VALUE_MAP = new HashMap<>();

    static {
        for (PictureEditActionEnum item : PictureEditActionEnum.values()) {
            VALUE_MAP.put(item.value, item);
        }
    }

    /**
     * 根据 value 获取枚举
     */
    public static PictureEditActionEnum getEnumByValue(String value) {
        if (value == null) {
            return null;
        }
        return VALUE_MAP.get(value);
    }
}
